package main

import (
	"fmt"
	"time"
)
func worker(id int,c chan int){
	for{
		n:=<-c
		fmt.Printf("%d %c\n",id,n)
	}
}
func createworker(id int)chan<- int{
	c:=make(chan int)
	go worker(id,c)
	return c
}

func channelDemo(){
	channels:=make([]chan <-int,10)
	for i:=0;i<len(channels);i++{
		channels[i]=createworker(i)
	}
	for i:=0;i<10;i++{
		channels[i]<-'a'+i
	}
	for i:=0;i<10;i++{
		channels[i]<-'A'+i
	}

	time.Sleep(time.Second)
}

func workeClosechannle(c chan int){
	for v:=range c{

		fmt.Println(v)
	}
}
func closeChannle(){
	c:=make(chan int)
	go workeClosechannle(c)
	c<-9
	c<-8
	c<-7
	close(c)
	time.Sleep(time.Second)
}

func main() {
	channelDemo()
	//closeChannle()
}
